/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author HuyNVK
 */
@Entity
@Table(name = "PROJECT")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Project.findAll", query = "SELECT p FROM Project p"),
    @NamedQuery(name = "Project.findByProjectID", query = "SELECT p FROM Project p WHERE p.projectID = :projectID"),
    @NamedQuery(name = "Project.findByName", query = "SELECT p FROM Project p WHERE p.name = :name"),
    @NamedQuery(name = "Project.findByDescription", query = "SELECT p FROM Project p WHERE p.description = :description"),
    @NamedQuery(name = "Project.findByStartedDate", query = "SELECT p FROM Project p WHERE p.startedDate = :startedDate"),
    @NamedQuery(name = "Project.findByEndedDate", query = "SELECT p FROM Project p WHERE p.endedDate = :endedDate")})
    public class Project implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ProjectID")
    private String projectID;
    @Basic(optional = false)
    @Column(name = "Name")
    private String name;
    @Column(name = "Description")
    private String description;
    @Column(name = "StartedDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date startedDate;
    @Column(name = "EndedDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date endedDate;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "projectID")
    private Collection<Defectlog> defectlogCollection;
    @JoinColumn(name = "StatusID", referencedColumnName = "ProjectStatusID")
    @ManyToOne
    private Projectstatus statusID;
    @JoinColumn(name = "PM", referencedColumnName = "EmployeeID")
    @ManyToOne(optional = false)
    private Employee pm;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "project")
    private Collection<Employeeproject> employeeprojectCollection;

    public Project() {
    }

    public Project(String projectID) {
        this.projectID = projectID;
    }

    public Project(String projectID, String name) {
        this.projectID = projectID;
        this.name = name;
    }

    public String getProjectID() {
        return projectID;
    }

    public void setProjectID(String projectID) {
        this.projectID = projectID;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getStartedDate() {
        return startedDate;
    }

    public void setStartedDate(Date startedDate) {
        this.startedDate = startedDate;
    }

    public Date getEndedDate() {
        return endedDate;
    }

    public void setEndedDate(Date endedDate) {
        this.endedDate = endedDate;
    }

    @XmlTransient
    public Collection<Defectlog> getDefectlogCollection() {
        return defectlogCollection;
    }

    public void setDefectlogCollection(Collection<Defectlog> defectlogCollection) {
        this.defectlogCollection = defectlogCollection;
    }

    public Projectstatus getStatusID() {
        return statusID;
    }

    public void setStatusID(Projectstatus statusID) {
        this.statusID = statusID;
    }

    public Employee getPm() {
        return pm;
    }

    public void setPm(Employee pm) {
        this.pm = pm;
    }

    @XmlTransient
    public Collection<Employeeproject> getEmployeeprojectCollection() {
        return employeeprojectCollection;
    }

    public void setEmployeeprojectCollection(Collection<Employeeproject> employeeprojectCollection) {
        this.employeeprojectCollection = employeeprojectCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (projectID != null ? projectID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Project)) {
            return false;
        }
        Project other = (Project) object;
        if ((this.projectID == null && other.projectID != null) || (this.projectID != null && !this.projectID.equals(other.projectID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.Project[ projectID=" + projectID + " ]";
    }
    
}
